<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>

<script type="text/javascript" src="<%=request.getContextPath()%>/js/common.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/validators/product.js"></script>

<script type="text/javascript">
  var attSize = parseInt('<s:property value="cases.attachJSON.size()"/>');
</script>

 <div class="f_l margin1" style="width:100%">
    <div style="height:24px;color:red" align="center" id="errorInfo">${failInfo }</div>
   	<div style="height:24px;color:red;font-weight:bold" align="left">新增产品</div>
    <s:form enctype="multipart/form-data" id="submitForm" action="product!update" method="post" theme="simple">
   	<table>
   		<tbody>
   			<tr>
   				<td width="18%"><s:text name="产品名称"/>：</td>
   				<td><input type="text" name="product.name" value="${product.name}"/></td>
   			</tr>
   			<tr>
   				<td valign="middle"><s:text name="标题图片"/>：</td>
   				<td>
   				    <s:iterator value="product.attachJSON" var="pic">
	   					<div><s:property value='#pic.get("attName")'/>&nbsp;<a onclick="javascript:deleteAttAndSize(this,'<s:property value="#pic.get('attId')" />','submitForm','product')" href="javascript:void(0);"  style="color:red">删除</a></div>
	   			    </s:iterator>
	   				<a href="javascript:void(0)" onclick="updateAttachment(this,'product')">添加图片</a>
   				</td>
   			</tr>
   			
   			<tr>
   				<td><s:text name="价格"/>：</td>
   				<td><input type="text" name="product.price" value="${product.price}"/><s:text name="(元)"/></td>
   			</tr>
   			<tr>
   				<td><s:text name="是否积分兑换"/>：</td>
   				<td>
   				  <select name="product.exchange">
   				      <option <s:if test="%{product.exchange == 0}">selected="selected"</s:if> value="0">-- 否 --</option>
   				      <option <s:if test="%{product.exchange == 1}">selected="selected"</s:if> value="1">-- 是 --</option>
   				    </select>  
   				</td>
   			</tr>
   			<tr>
   				<td><s:text name="积分"/>：</td>
   				<td><input type="text" name="product.points" value="${product.points }"/></td>
   			</tr>
   			<tr>
   				<td><s:text name="是否热卖"/>：</td>
   				<td>
   				  <select name="product.hot">
   				      <option <s:if test="%{product.hot == 0}">selected="selected"</s:if> value="0">-- 否 --</option>
   				      <option <s:if test="%{product.hot == 1}">selected="selected"</s:if> value="1">-- 是 --</option>
   				    </select>  
   				</td>
   			</tr>
   			<tr>
   			    <td><s:text name="产品简述"/>：</td>
   				<td><textarea rows="4" cols="50" name="product.brief">${product.brief}</textarea></td>
   			</tr>
   			<tr> 
   				<td align="left">
   					<input type="submit" value="确认" onclick="return doValidate(event);" />
  				</td>
   				<td align="left">
   					<input type="button" value="取消" onclick="javascript:history.back(-1);"/>
   				</td>
   			 </tr>
   		</tbody>
   	</table>
   	
   	<input type="hidden" id="product.id" name="product.id" value="${product.id}">
   	<input type="hidden" id="product.publisherId" name="product.publisherId" value="${product.publisherId}">
   	<input type="hidden" id="product.publisherName" name="product.publisherName" value="${product.publisherName}">
    </s:form>
  </div>
  